package aom.ju.ss.view.user.shop.management.order

import aom.ju.ss.R
import aom.ju.ss.databinding.PostGoodsBinding
import aom.ju.ss.utils.data
import aom.ju.ss.utils.http.LP_API
import aom.ju.ss.utils.http.OKHttpUtils
import aom.ju.ss.utils.show
import aom.ju.ss.view.base.BaseActivity

/**
 * 发货
 */
class PostGoods : BaseActivity() {
    private lateinit var binding: PostGoodsBinding
    override fun init() {
        binding = viewBinding as PostGoodsBinding

        binding.fh.setOnClickListener {
            if (binding.num.text.length < 5) {
                "请输入正确的快递单号"
                return@setOnClickListener
            }
            OKHttpUtils(activity)
                .SetApiUrl(LP_API.shop_order_shipment)
                .SetKey("id", "courier_no")
                .SetValue(data, binding.num.text.toString())
                .POST(this)
        }


    }

    override fun ok(jsonString: String, httpTY: String) {
        super.ok(jsonString, httpTY)
        "发货成功".show
        setResult(RESULT_OK)
        finish()
    }

    override fun error(e: String, jsonString: String, httpTY: String) {
        super.error(e, jsonString, httpTY)
        e.show
    }

    override val lay: Int = R.layout.post_goods
}